/******************************************************
  File: src/display.c
  Description: Audio Cup Display Update ( object )
  Author: Brant Anderson
  Date: 10/30/01
  Last Update: 10/30/01
  Status: Temperary For The Demo
  To Do:
 ******************************************************/



#include <stdio.h>
#include "../include/display.h"


void menuDisplay( SongInfo songinf ) {
	/** Show Song Information **/
    if( songinf.scroller == 1 ) {
    	/* Track Number ( wTrack col(1) row(1) {string} ) */
    	sock_send_string( sock, "widget_add A wTrack string\n" );
    	Track  = YES;
    	sprintf( wTrack, "%s", songinf.track );
    	sprintf( tmp, "widget_set A wTrack 1 1 {%s}\n", wTrack );
    	sock_send_string (sock, tmp);
    	/* Song Title ( wSong left(4) top(1) right(20) bottom(1) [h/v](h) speed {string} ) */
    	sock_send_string( sock, "widget_del A wSong\n" );
    	sock_send_string( sock, "widget_add A wSong scroller\n" );
    	Song   = SCROLL;
    	sprintf( wSong, "%s", songinf.title );
    	sprintf( tmp, "widget_set A wSong 4 1 20 1 h 2 {%s}\n", wSong );
    	sock_send_string( sock, tmp );   	
    	/* Artist Name ( wArtist col(1) row(2) {string} ) */
    	sock_send_string( sock, "widget_add A wArtist string\n" );
    	Artist = YES;
    	sprintf( wArtist, "%s", songinf.artist );
    	sprintf( tmp, "widget_set A wArtist 1 2 {%s}\n", wArtist );
    	sock_send_string (sock, tmp);
    	/* Album Title ( wAlbum col(1) row(4) {string} ) */
    	sock_send_string( sock, "widget_add A wAlbum string\n" );
    	Album  = YES;
    	sprintf( wAlbum, "%s", songinf.album );
    	sprintf( tmp, "widget_set A wAlbum 1 3 {%s}\n", wAlbum );
    	sock_send_string (sock, tmp);
    	/* Time mm:ss ( wTime col(1) row(4) {string} ) */
    	sock_send_string( sock, "widget_add A wTime string\n" );
    	Time   = YES;
    	sprintf( wTime, "00:00" );
    	sprintf( tmp, "widget_set A wTime 1 4 {%s}\n", wTime );
    	sock_send_string (sock, tmp);
    	/* Graph range 0:70 ( wGraph col(7) row(4) range ) */
    	sock_send_string( sock, "widget_add A wGraph hbar\n" );
    	Graph  = YES;
    	wGraph = 0;
    	sprintf( tmp, "widget_set A wGraph 7 4 %d\n", wGraph );
    	sock_send_string (sock, tmp);
    } else {
    	/* Track Number ( wTrack col(1) row(1) {string} ) */
    	sock_send_string( sock, "widget_add A wTrack string\n" );
    	Track  = YES;
    	sprintf( wTrack, "%s", songinf.track );
    	sprintf( tmp, "widget_set A wTrack 1 1 {%s}\n", wTrack );
    	sock_send_string (sock, tmp);
    	/* Song Title ( wSong col(4) row(1) {string} ) */
    	sock_send_string( sock, "widget_del A wSong\n" );
    	sock_send_string( sock, "widget_add A wSong string\n" );
    	Song = YES;
	    sprintf( wSong, "%s", songinf.title );
	    sprintf( tmp, "widget_set A wSong 4 1 {%s}\n", wSong );
	    sock_send_string( sock, tmp );
    	/* Artist Name ( wArtist col(1) row(2) {string} ) */
    	sock_send_string( sock, "widget_add A wArtist string\n" );
    	Artist = YES;
    	sprintf( wArtist, "%s", songinf.artist );
    	sprintf( tmp, "widget_set A wArtist 1 2 {%s}\n", wArtist );
    	sock_send_string (sock, tmp);
    	/* Album Title ( wAlbum col(1) row(4) {string} ) */
    	sock_send_string( sock, "widget_add A wAlbum string\n" );
    	Album  = YES;
    	sprintf( wAlbum, "%s", songinf.album );
    	sprintf( tmp, "widget_set A wAlbum 1 3 {%s}\n", wAlbum );
    	sock_send_string (sock, tmp);
    	/* Time mm:ss ( wTime col(1) row(4) {string} ) */
    	sock_send_string( sock, "widget_add A wTime string\n" );
    	Time   = YES;
    	sprintf( wTime, "00:00" );
    	sprintf( tmp, "widget_set A wTime 1 4 {%s}\n", wTime );
    	sock_send_string (sock, tmp);
    	/* Graph range 0:70 ( wGraph col(7) row(4) range ) */
    	sock_send_string( sock, "widget_add A wGraph hbar\n" );
    	Graph  = YES;
    	wGraph = 0;
    	sprintf( tmp, "widget_set A wGraph 7 4 %d\n", wGraph );
    	sock_send_string (sock, tmp);
    }   
}

void menuDisplayTime( unsigned char min, unsigned char sec, unsigned long dur ) {
	/* Time mm:ss ( wTime col(1) row(4) {string} ) */
	Time   = YES;
	sprintf( wTime, "%.2d:%.2d", min, sec );
	sprintf( tmp, "widget_set A wTime 1 4 {%s}\n", wTime );
	sock_send_string (sock, tmp);
	/* Graph range 0:70 ( wGraph col(7) row(4) range ) */
	Graph  = YES;
	wGraph = 70*(min*60+sec)/dur;
	sprintf( tmp, "widget_set A wGraph 7 4 %d\n", wGraph );
	sock_send_string (sock, tmp);
	Track  = YES;
	Song   = YES;
	Artist = YES;
	Album  = YES;
	Title  = NO;
	Item1  = NO;
	Item2  = NO;
	Item3  = NO;
	Vol    = NO;
	Tre    = NO;
	Bas    = NO;
}

